// Copyright (c) 2009, 백괴사전 all rights reserved.
// Distributed under GNU General Public License v3.
// Read LICENSE for more information.

var upfgIsUngameMain=false;

function runLogoLinkMutator() {
 
	if(wgPageName.indexOf(":")==-1)
		return true;
 
	var upflSlicedPageName=wgPageName.split(":");
	var upflPageNamespace=upflSlicedPageName[0];
	upflSlicedPageName=upflSlicedPageName[1].split("/");
	var upflPageName=upflSlicedPageName[0];
	upflSlicedPageName=null;
 
	if(upflPageNamespace=="백괴게임" || upflPageNamespace=="백괴게임토론") {
		var upflChilds=document.getElementById("p-logo").childNodes;
		for(var upflLoopIndex=0;upflLoopIndex<upflChilds.length;upflLoopIndex++) {
			if(upflChilds[upflLoopIndex].tagName=="a" || upflChilds[upflLoopIndex].tagName=="A") {
				if(sifgIsUngameMain==false)
					upflChilds[upflLoopIndex].href="/wiki/백괴게임:"+upflPageName;
				else
					upflChilds[upflLoopIndex].href="/wiki/백괴게임:대문";
				break;
			}
		}
	} else if(upflPageNamespace=="백괴뉴스" || upflPageNamespace=="백괴뉴스토론" || upflPageNamespace=="백괴낱말사전" || upflPageNamespace=="백괴낱말사전토론" || upflPageNamespace=="백괴식당" || upflPageNamespace=="백괴식당토론" || upflPageNamespace=="백괴해설서" || upflPageNamespace=="백괴해설서토론") {
		var upflChilds=document.getElementById("p-logo").childNodes;
		for(var upflLoopIndex=0;upflLoopIndex<upflChilds.length;upflLoopIndex++) {
			if(upflChilds[upflLoopIndex].tagName.toUpperCase()=="a") {
				upflChilds[upflLoopIndex].href="/wiki/"+upflPageNamespace.replace(/토론/,"")+":대문";
				break;
			}
		}
	}
}

addOnloadHook(runLogoLinkMutator);